/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx.controller;

import cn.webrx.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.PrintWriter;
import java.time.LocalDate;
import java.util.*;

/**
 * <p>Project: smvc2022 - IndexController
 * <p>Powered by webrx On 2022-03-18 16:21:11
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
@RestController
public class IndexController {
    @GetMapping("/s1")
    public String[] s1() {
        return new String[]{"java", "javascript", "中文编程", "html5"};
    }

    @GetMapping("/s2")
    public User s2() {
        User u = new User();
        u.setId(10);
        u.setName("李四");
        u.setAge(20);
        return u;
    }

    @GetMapping("/s3")
    public User[] s3() {
        return new User[]{new User(100,"李强",21),new User(200,"周洋在",22),new User(300,"张三丰",23)};
    }

    @GetMapping("/s4")
    public List<Date> s4() {
        List<Date> list = new ArrayList<>();
        //yyyy-MM-dd
        list.add(new Date());
        list.add(new Date());
        list.add(new Date());
        list.add(new Date());
        return list;
    }

    @RequestMapping("/s5")
    public Set<LocalDate> s5(){
        Set<LocalDate> set = new HashSet<>();
        set.add(LocalDate.now());
        set.add(LocalDate.of(1985,10,23));
        set.add(LocalDate.of(2022,3,1));
        return set;
    }
}
